package com.hhsjtest.bus_advert.businessdata

import com.hhsjdesign.dynamicui.annoprocess.ABusinessBean
import com.hhsjdesign.dynamicui.annoprocess.AFromJSON
import com.hhsjdesign.dynamicui.businessdata.IViewable
import org.json.JSONObject


/**
 * 广告
 */
@ABusinessBean("advert")
class Advert : IViewable.IViewableTransformer {

    var itemId: String? = null
    var title: String? = null

    override fun toViewable(): IViewable<Advert> {
        return IViewable<Advert>().apply {
            this.businessData = this@Advert as Advert
            this.viewId = itemId
            this.title = this@Advert.title
        }
    }

    companion object {
        @JvmStatic
        @AFromJSON
        fun fromJSON(jo: JSONObject): Advert {
            return Advert().apply {
                this.itemId = jo.optString("id")
                this.title = jo.optString("title")
            }
        }
    }
}